﻿package org.flixel.plugin
{
    import org.flixel.*;

    public class DebugPathDisplay extends FlxBasic
    {
        protected var _paths:Array;

        public function DebugPathDisplay()
        {
            this._paths = new Array();
            active = false;
            return;
        }// end function

        override public function destroy() : void
        {
            super.destroy();
            this.clear();
            this._paths = null;
            return;
        }// end function

        override public function draw() : void
        {
            if (!FlxG.visualDebug || ignoreDrawDebug)
            {
                return;
            }
            if (cameras == null)
            {
                cameras = FlxG.cameras;
            }
            var _loc_1:uint = 0;
            var _loc_2:* = cameras.length;
            while (_loc_1 < _loc_2)
            {
                
                this.drawDebug(cameras[_loc_1++]);
            }
            return;
        }// end function

        override public function drawDebug(param1:FlxCamera = null) : void
        {
            var _loc_3:FlxPath = null;
            if (param1 == null)
            {
                param1 = FlxG.camera;
            }
            var _loc_2:* = this._paths.length - 1;
            while (_loc_2 >= 0)
            {
                
                _loc_3 = this._paths[_loc_2--] as FlxPath;
                if (_loc_3 != null && !_loc_3.ignoreDrawDebug)
                {
                    _loc_3.drawDebug(param1);
                }
            }
            return;
        }// end function

        public function add(param1:FlxPath) : void
        {
            this._paths.push(param1);
            return;
        }// end function

        public function remove(param1:FlxPath) : void
        {
            var _loc_2:* = this._paths.indexOf(param1);
            if (_loc_2 >= 0)
            {
                this._paths.splice(_loc_2, 1);
            }
            return;
        }// end function

        public function clear() : void
        {
            var _loc_2:FlxPath = null;
            var _loc_1:* = this._paths.length - 1;
            while (_loc_1 >= 0)
            {
                
                _loc_2 = this._paths[_loc_1--] as FlxPath;
                if (_loc_2 != null)
                {
                    _loc_2.destroy();
                }
            }
            this._paths.length = 0;
            return;
        }// end function

    }
}
